﻿<%@ WebHandler Language="C#" Class="SIPO.Web.AjaxHandler.Loaddata.getrecimpositionbyyearreport" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using SIPO.Library.DataAccess.Transaction;
using SIPO.Library.DomainObject.Transaction;
using SIPO.Library.Enum;
using SIPO.Web.Support;
using Newtonsoft.Json.Linq;
using System.Text;
namespace SIPO.Web.AjaxHandler.Loaddata
{
    public class getrecimpositionbyyearreport : SIPO.Web.BaseHandler
    {
        recImpositionRepo recImpositionDal = new recImpositionRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);
            decimal? debtorvalue = 0;
            decimal? ojkvalue = 0;
            int yearReport = 0;
            int impositionid = 0;
            decimal isFormula = 0;
            decimal? value = 0;
            decimal? minvalue = 0;
            decimal? maxvalue = 0;
            decimal? percentage = 0;
            int tarifId = 0;
            int impositionBaseId = 0;
            string yearreport = context.Request.Params["yearreport"].ToString();
            int subsubsectorid = Convert.ToInt32(context.Request.Params["subsubsectorid"]);
            int debtorsectorid = Convert.ToInt32(context.Request.Params["debtorsectorid"]);
            recImposition recImposition = recImpositionDal.GetByYearReport(yearreport, debtorsectorid, subsubsectorid);
            if (recImposition != null)
            {
                debtorvalue = recImposition.DebtorValue;
                ojkvalue = recImposition.OJKValue;
                yearReport = recImposition.YearReport;
                impositionid = recImposition.ImpositionID;

                isFormula = recImposition.IsFormula == true ? 1 : 0;
                value = recImposition.TariffValue == null ? 0 : recImposition.TariffValue;
                minvalue = recImposition.Minimal == null ? 0 : recImposition.Minimal;
                maxvalue = recImposition.Maximal == null ? 0 : recImposition.Maximal;
                percentage = recImposition.Percentage == null ? 0 : recImposition.Percentage;
                tarifId = (int)recImposition.TariffID;
                impositionBaseId = recImposition.ImpositionBaseID == null ? 0 : (int)recImposition.ImpositionBaseID;
            }
            StringBuilder sbProject = new StringBuilder();
            sbProject.Append("{");
            sbProject.AppendFormat("  {0}DebtorValue{0}:{0}{1}{0}", "\"", debtorvalue);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}OJKValue{0}:{0}{1}{0}", "\"", ojkvalue);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}YearReport{0}:{0}{1}{0}", "\"", yearReport);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}ImpositionID{0}:{0}{1}{0}", "\"", impositionid);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}IsFormula{0}:{0}{1}{0}", "\"", isFormula);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}Value{0}:{0}{1}{0}", "\"", value);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}MinValue{0}:{0}{1}{0}", "\"", minvalue);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}MaxValue{0}:{0}{1}{0}", "\"", maxvalue);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}Percentage{0}:{0}{1}{0}", "\"", percentage);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}TariffID{0}:{0}{1}{0}", "\"", tarifId);
            sbProject.Append(",");
            sbProject.AppendFormat("  {0}ImpositionBaseId{0}:{0}{1}{0}", "\"", impositionBaseId);
            sbProject.Append("}");

            context.Response.Write(sbProject.ToString());
        }

        public override bool IsReusable
        {
            get
            {
                return false;
            }
        }

    }
}